package com.finance.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.common.vo.PageVo;
import com.finance.dao.UserMapper;
import com.finance.entity.User;

@Service("UserService")
public class UserService {
	
	@Resource(name = "UserMapper")
	private UserMapper userMapper;
	
	/**
	 * 用户id查询
	 * @param userId
	 * @return
	 */
	public User selectByPrimaryKey(String userId){
		return userMapper.selectByPrimaryKey(userId);
	}
	
	/**
	 * 添加用户
	 * @param record
	 */
	public void insert(User record){
		userMapper.insert(record);
	}
	
	/**
	 * 选择性更新用户
	 * @param record
	 */
	public void updateByPrimaryKeySelective(User record){
		userMapper.updateByPrimaryKeySelective(record);
	}
	
	/**
	 * 更新用户
	 * @param record
	 */
	public void updateByPrimaryKey(User record){
		userMapper.updateByPrimaryKey(record);
	}
	
	public User findByPhone(String phone,Integer state){
		return userMapper.findByPhone(phone,state);
	}
	
	public PageVo<User> findPageBySearch(User search, int pageNum) {
		PageVo<User> page = new PageVo<User>(pageNum);
		page.setRows(3);
		List<User> list = userMapper.findByPageBySearch(search,
				page.getOffset(), page.getRows());
		int count = userMapper.countPageBySearch(search);
		page.setCount(count);
		page.setList(list);
		return page;
	}
	
	
 	public List<User> findByJurisdiction(Integer jurisdiction){
		return userMapper.findByJurisdiction(jurisdiction);
	}

}
